﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Kindohm.Life.Library
{
    public abstract class TerminalLifeForm : GrowingLifeForm
    {
        int maxHeartbeats;

        public int MaxHeartbeats
        {
            get { return this.maxHeartbeats; }
            set { this.maxHeartbeats = value; }
        }

        public override void RunHeartbeat()
        {
            base.RunHeartbeat();

            if (this.IsDead)
            {
                return;
            }

            if (this.Heartbeats >= this.MaxHeartbeats)
            {
                this.Die(CauseOfDeath.OldAge);
            }
        }

        public override void Die(CauseOfDeath cause)
        {
            base.Die(cause);
            Point point = this.Position;
            this.RemoveFromBoard();
            this.ProduceRemains(point);
        }

        

        protected abstract void ProduceRemains(Point position);


    }
}
